//
//  GCW_VideoCollectionViewCell.m
//  MooMusic
//
//  Created by 管晨雯 on 15/10/22.
//  Copyright © 2015年 wjy. All rights reserved.
//

#import "GCW_VideoCollectionViewCell.h"
#import "PrefixHeader.pch"
@implementation GCW_VideoCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    
    if (self) {
        self.backgroundImageView = [[UIImageView alloc]init];
        [self.contentView addSubview:self.backgroundImageView];
        
        self.typeLabel = [[UILabel alloc]init];
        [self.backgroundImageView addSubview:self.typeLabel];
        
        
        self.countLabel = [[UILabel  alloc]init];
        [self.backgroundImageView addSubview:self.countLabel];
        
        
        self.playButton = [UIButton  buttonWithType:UIButtonTypeCustom];
        [self.contentView addSubview:self.playButton];
    }
    
    return self;
    
}

- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes
{
    self.backgroundImageView.frame = CGRectMake(5 * WIDTH, 15 * HEIGH, 170 * WIDTH, 120 * HEIGH);
    self.backgroundImageView.backgroundColor = [UIColor orangeColor];
    self.backgroundImageView.layer.cornerRadius = 5;
    self.backgroundImageView.layer.masksToBounds = YES;
    
    
    self.typeLabel.frame = CGRectMake(30 * WIDTH,30 * HEIGH , 120 * WIDTH, 40 * HEIGH);
    self.typeLabel.textColor = [UIColor whiteColor];
    self.typeLabel.textAlignment = 1;
    self.typeLabel.font = [UIFont systemFontOfSize:20];
//    self.typeLabel.backgroundColor = [UIColor blackColor];
    
    
    self.countLabel.frame = CGRectMake(50 * WIDTH, 50 * HEIGH, 80 * WIDTH, 40 * HEIGH);
    self.countLabel.textColor = [UIColor whiteColor];
    self.countLabel.textAlignment = 1;
    self.countLabel.font = [UIFont systemFontOfSize:10];
//    self.countLabel.backgroundColor = [UIColor brownColor];
    

    self.playButton.frame = CGRectMake(135 * WIDTH, 90 * HEIGH, 30 * WIDTH, 30 * HEIGH);
    [self.playButton setImage:[UIImage imageNamed:@"play@2x.png"] forState:UIControlStateNormal];
    
    [self.playButton setImage:[UIImage imageNamed:@"iconfont-yulebofangzhong-2.png"] forState:UIControlStateNormal];
    self.playButton.backgroundColor = [UIColor cyanColor];
    [self.playButton addTarget:self action:@selector(playButton:) forControlEvents:UIControlEventTouchUpInside];
//    self.playButton.backgroundColor = [UIColor cyanColor];
    

}
- (void)playButton:(UIButton *)sender
{
    self.block(sender.tag);
    if (sender.selected == NO) {
        [self.playButton setImage:[UIImage imageNamed:@"play@2x.png"] forState:UIControlStateNormal];
    } else {
        [self.playButton setImage:[UIImage imageNamed:@"iconfont-yulebofangzhong-2.png"] forState:UIControlStateNormal];
    }
    
    sender.selected = !sender.selected;
}


@end
